<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>赛事</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>

    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header" style="height: 1.66rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99;">
    <div class="match_top">
        <div class="flex_center pt20 pb15" style="box-shadow: 0rem 0rem 0.08rem 0rem rgba(0, 0, 0, 0.03);">
            <div class="match_top_type" tapmode onclick="UrlNoAnimation('match_index')">看点</div>
            <div class="match_top_type on" tapmode>数据</div>
        </div>
        <ul class="math_list_type" id="match_nav">
            <!--<li tapmode class="on">CUBA(男子组)</li>
            <li tapmode>CUBA(女子组)</li>
            <li tapmode>CUFA(超冠组)</li>
            <li tapmode>CUFA(超冠组)</li>
            <li tapmode>CUFA(超冠组)</li>-->
        </ul>
    </div>
</div>

<div class="pl30 pr30 pad-height" style="padding-top: 2.4rem;">
    <div class="match-kinds">
        <div class="choose-season">
            <select name="" id="select_season" class="season-select">
                <!--<option value="">19/20</option>
                <option value="">19/20</option>
                <option value="">19/20</option>-->
            </select>
        </div>
        <div class="kinds-choose">
            <ul>
                <li data-type="1" class="on">排名</li>
                <li data-type="2">赛程</li>
                <li data-type="3">球员榜</li>
            </ul>
        </div>
    </div>
</div>
<div class="section">
    <div class="view" style="display: block;">
        <ul class="math_area_type mt10" id="match_area">
            <!--<li tapmode class="on">西北赛区</li>
            <li tapmode>东北赛区</li>
            <li tapmode>西南赛区</li>
            <li tapmode>东南赛区</li>
            <li tapmode>总决赛</li>-->
        </ul>

        <div class="area-match-list" id="areaMatchList">
            <div class="area-view">
                <h6 class="area-title mb15">排位赛</h6>
                <div class="area-match flex8q">
                    <ul id="areaMatch">

                    </ul>
                </div>
            </div>
        </div>

        <div class="area-match-list" style="display: none;" id="match32List">
            <div class="area-view" style="padding: 0;">
                <div class="area-match flex16q">
                    <div class="ban-area"><span class="icon">上半区</span></div>
                    <div id="matchList_data"></div>
                    <div class="ban-area"><span class="icon">下半区</span></div>
                </div>
            </div>
        </div>

        <div class="area-list-view">
            <h6 class="area-title mb15">小组赛</h6>
            <div id="groupHtml">

            </div>
        </div>

        <div class="footer-section"></div>
    </div>
    <div class="view pl30 pr30" style="display: none;">
        <div class="select-match">
            <p class="season-select" id="curr_schedule">四分之一决赛</p>
            <select name="" id="select_schedule" class="season-select-choose">
                <!--<option value="四分之一决赛">四分之一决赛</option>
                <option value="八分之一决赛">八分之一决赛</option>
                <option value="二分之一决赛">二分之一决赛</option>
                <option value="总决赛">总决赛</option>-->
            </select>
        </div>
        <div class="schedule">
            <ul id="scheduleHtml">
                <!--<li>
                    <div class="time">08-27 01:45</div>
                    <div class="schedule-team">
                        <div class="team flex-end">
                            <p class="single-ellipsis t-r">东南大学</p>
                            <div class="team-icon ml10 bg-cover" style="background: url('../../icon/Icon.png')"></div>
                        </div>
                        <div class="team-score">2:1</div>
                        <div class="team flex-start">
                            <div class="team-icon mr10 bg-cover" style="background: url('../../icon/Icon.png')"></div>
                            <p class="single-ellipsis">东南大学</p>
                        </div>
                    </div>
                </li>-->
            </ul>
        </div>


        <div class="footer-section"></div>
    </div>
    <div class="view" style="display: none;">
        <div class="rank-view">
            <div class="rank-label">
                <ul id="rank_label">
                    <!--<li class="on">得分</li>
                    <li>助攻</li>-->
                </ul>
            </div>
            <div class="rank-item">
                <div class="item-name pl20 pr30">
                    <p class="wt1">姓名</p>
                    <p class="wt2">球队</p>
                    <p class="wt3 label-name" id="scoreTitle">得分</p>
                </div>
                <ul class="pl20 pr30" id="playerRankHtml">
                    <!--<li>
                        <div class="wt1">
                            <h6>1.</h6>
                            <div class="member-info">
                                <div class="info-icon bg-cover mr15"
                                     style="background: url('../../icon/Icon.png')"></div>
                                <p class="name">迈克尔·乔丹</p>
                            </div>
                        </div>
                        <div class="wt2">广州大学</div>
                        <div class="wt3 c-primary">23</div>
                    </li>-->
                </ul>
            </div>
        </div>
    </div>
</div>


<div id="footer" class="border-t">
    <ul class="flex-wrap">
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">首页</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">圈子</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">
            <div class="school-logo">
                <img id="school_path" src="" alt="">
            </div>
        </li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con active">在看</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">我的</li>
    </ul>
</div>

</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    var curr_schedule_id = '';//当前赛程id
    var curr_season_id = '';//当前赛季id
    var match_area_id = '';//当前区域id
    var ball_kinds_id = '';//当前球员榜左侧id
    var kinds_type = 1;//类型：1:排名 2：赛程 3：球员榜
    var firstType = 2;//类型：1比赛 2数据
    var category_id = '';//分类id
    apiready = function () {
        setFixStatusBar(); //设置状态栏
        pop.loading();
        keybackListener()
        $('#school_path').attr('src', $api.getStorage('schoolPath'));


        getMatchNav();//获取导航

        isIosX()

    }


    //获取导航
    function getMatchNav() {
        var param = {
            token: $api.getStorage('token'),
            type: firstType,//类型：1比赛 2数据
        }
        getAjax(Interface.get_nave, param, function (res) {
            var data = res.data;
            if (isDefine(data)) {
                var navHtml = '';
                for (var i = 0; i < data.length; i++) {
                    var info = data[i];
                    if (info.id == 156) {
                        navHtml = '<li tapmode class="on" data-id="' + info.id + '" data-type="' + info.stype + '">' + info.title + '</li>' + navHtml;
                        category_id = info.id;
                        getSeason(1);
                        getRanking();

                    } else {
                        navHtml += '<li tapmode data-id="' + info.id + '" data-type="' + info.stype + '">' + info.title + '</li>';
                    }
                }

                $("#match_nav").html(navHtml)

            }
        }, function (error) {
            pop.notice(error.msg);
        })
    }

    //获取赛季 获取赛程 获取赛区
    function getSeason(s_type) {
        if (s_type == 3) {
            var param = {
                token: $api.getStorage('token'),
                type: s_type,//类型：1：获取赛季 2：获取赛程 3：赛区
                nav_top_id: category_id,//当type为3的时候必须传，导航id
            }
        } else {
            var param = {
                token: $api.getStorage('token'),
                type: s_type,//类型：1：获取赛季 2：获取赛程 3：赛区
            }
        }
        getAjax(Interface.get_season, param, function (res) {
            var data = res.data;
            if (isDefine(data)) {
                if (s_type == 1) {
                    var season = '';
                    $.each(data, function (i, item) {
                        if (i == 0) {
                            season += '<option value="' + item.id + '" selected>' + item.title + '</option>';
                            curr_season_id = item.id;
                            getSeason(3);
                        } else {
                            season += '<option value="' + item.id + '">' + item.title + '</option>'
                        }
                    })

                    $('#select_season').html(season)
                } else if (s_type == 2) {
                    var schedule = '';
                    $.each(data, function (i, item) {
                        if (i == 0) {
                            schedule += '<option value="' + item.title + '" data-id="' + item.id + '" selected>' + item.title + '</option>'
                            $("#curr_schedule").html(item.title);
                            curr_schedule_id = item.id;
                            getMatchData()

                        } else {
                            schedule += '<option value="' + item.title + '" data-id="' + item.id + '">' + item.title + '</option>'
                        }
                    })

                    $('#select_schedule').html(schedule)
                } else if (s_type == 3) {
                    var match_area = '';
                    $.each(data, function (i, item) {
                        if (i == 0) {
                            match_area += '<li tapmode class="on" data-id="' + item.id + '">' + item.title + '</li>'
                            match_area_id = item.id;
                            getMatchData()
                            getGroupData()

                        } else {
                            match_area += '<li tapmode data-id="' + item.id + '">' + item.title + '</li>'
                        }
                    })
                    $('#match_area').html(match_area)
                }

            }
        }, function (error) {
            pop.notice(error.msg)
        })
    }

    //获取赛事球员榜左侧导航
    function getRanking() {
        var param = {
            token: $api.getStorage('token'),
            nav_top_id: category_id,//导航id
        }
        getAjax(Interface.get_player_list, param, function (res) {
            var data = res.data;
            if (isDefine(data)) {
                var labelHtml = '';
                for (var i = 0; i < data.length; i++) {
                    var info = data[i];
                    if (i == 0) {
                        labelHtml += '<li tapmode class="on" data-id="' + info.type_id + '">' + info.title + '</li>';
                        ball_kinds_id = info.type_id;
                        $('#scoreTitle').html(info.title)
                    } else {
                        labelHtml += '<li tapmode data-id="' + info.type_id + '">' + info.title + '</li>';
                    }
                }

                $("#rank_label").html(labelHtml)

            }
        }, function (error) {
            pop.notice(error.msg);
        })
    }

    //获取数据
    function getMatchData() {
        if (kinds_type == 1) {
            var param = {
                token: $api.getStorage('token'),
                nav_top_id: category_id,
                season_id: curr_season_id,//赛季id
                type: kinds_type,//类型：1:排名 2：赛程 3：球员榜
                zone_id: match_area_id,//当type为1的时候必须带入：赛区id
            }
        } else if (kinds_type == 2) {
            var param = {
                token: $api.getStorage('token'),
                nav_top_id: category_id,
                season_id: curr_season_id,//赛季id
                type: kinds_type,//类型：1:排名 2：赛程 3：球员榜
                schedule_id: curr_schedule_id,//当type为2的时候必须带入：赛程id
            }
        } else if (kinds_type == 3) {
            var param = {
                token: $api.getStorage('token'),
                nav_top_id: category_id,
                season_id: curr_season_id,//赛季id
                type: kinds_type,//类型：1:排名 2：赛程 3：球员榜
                type_id: ball_kinds_id,//当type为3的时候必须带入：球员榜左侧导航id
            }
        }
        getAjax(Interface.get_rank, param, function (res) {
            var data = res.data;
            if (isDefine(data)) {
                if (kinds_type == 1) {

                    if(match_area_id == 170){
                        $("#areaMatchList").show();
                        $("#match32List").hide();
                        var areaMatch = '';
                        $.each(data,function (i, item) {

                            var areaMatchInfo = getFinalsMatch(item);
                            areaMatch = '<div class="area-view">' +
                                '                <h6 class="area-title mb15">保级赛</h6>' +
                                '                <div class="area-match flex8q">' +
                                '                    <ul id="areaMatch"><li class="flex4">' + areaMatchInfo + '</li></ul>' +
                                '                </div>' +
                                '            </div>'

                        })
                        $("#areaMatchList").html(areaMatch);

                    }else {
                        $("#areaMatchList").hide();
                        $("#match32List").show();
                        var areaMatchInfo = matchList(data,3);
                        var areaMatch = '<div class="area-view">' +
                            '                <div class="area-match flex8q">' +
                            '                    <ul id="areaMatch">' + areaMatchInfo + '</ul>' +
                            '                </div>' +
                            '            </div>'

                        $("#matchList_data").html(areaMatch);

                    }

                    getGroupData()
                } else if (kinds_type == 2) {
                    var scheduleHtml = '';
                    $.each(data, function (i, item) {
                        var teamParam1 = {"team_id": item.team_one_data.id};//左侧队伍id
                        var teamParam2 = {"team_id": item.team_two_data.id};//右侧队伍id
                        scheduleHtml += '<li>' +
                            '                    <div class="time">' + item.date + '</div>' +
                            '                    <div class="schedule-team">' +
                            '                        <div class="team flex-end" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                            '                            <p class=" t-r">' + item.team_one_data.title + '</p>' +
                            '                            <div class="team-icon ml10 bg-cover" style="background: url(' + ajaxUrl + item.team_one_data.icon_path + ')"></div>' +
                            '                        </div>' +
                            '                        <div class="team-score">' + item.team_one_data.team_one_fen + ':' + item.team_two_data.team_two_fen + '</div>' +
                            '                        <div class="team flex-start" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                            '                            <div class="team-icon mr10 bg-cover" style="background: url(' + ajaxUrl + item.team_two_data.icon_path + ')"></div>' +
                            '                            <p class="">' + item.team_two_data.title + '</p>' +
                            '                        </div>' +
                            '                    </div>' +
                            '                </li>'

                    })
                    $("#scheduleHtml").html(scheduleHtml);

                } else if (kinds_type == 3) {

                    var playerRankHtml = '';
                    $.each(data, function (i, item) {
                        var _index = parseInt(i) + 1;
                        var playerParam = {"player_id": item.player_id, "status": 2};//队员id
                        var teamParam = {"team_id": item.player_data.team_id};//队伍id
                        playerRankHtml += '<li>' +
                            '                        <div class="wt1">' +
                            '                            <h6>' + _index + '.</h6>' +
                            '                            <div class="member-info" tapmode onclick=\'commonUrl("team_member",' + jsonChange(playerParam) + ')\'>' +
                            '                                <div class="info-icon bg-cover mr15"' +
                            '                                     style="background: url(' + ajaxUrl + item.player_data.icon_path + ')"></div>' +
                            '                                <p class="name">' + item.player_data.name + '</p>' +
                            '                            </div>' +
                            '                        </div>' +
                            '                        <div class="wt2" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam) + ')\'>' + item.player_data.team_title + '</div>' +
                            '                        <div class="wt3 c-primary">' + item.breach + '</div>' +
                            '                    </li>'

                    })
                    $("#playerRankHtml").html(playerRankHtml);

                }
            } else {
                if (kinds_type == 1) {

                    $("#match32List").hide()
                    $("#areaMatchList").html(noData);

                    getGroupData()

                } else if (kinds_type == 2) {
                    $("#scheduleHtml").html(noData);

                } else if (kinds_type == 3) {
                    $("#playerRankHtml").html(noData);
                }


            }
            pop.close();
        }, function (error) {
            pop.notice(error.msg);
            pop.close();
        })
    }

    //获取赛事数据，小组数据
    function getGroupData() {
        var param = {
            token: $api.getStorage('token'),
            nav_top_id: category_id,
            season_id: curr_season_id,//赛季id
            zone_id: match_area_id,//赛区id
        }
        getAjax(Interface.get_small_group, param, function (res) {
            var data = res.data;

            if (isDefine(data)) {

                var groupHtml = '';
                $.each(data, function (i, item) {
                    var liHtml = '';
                    if (item.leixing_type == 1) {
                        $.each(item.data, function (j, jtem) {
                            var _index = parseInt(j) + 1;
                            var teamParam = {"team_id": jtem.team_id};//右侧队伍id
                            liHtml += '<li>' +
                                '           <div class="group-list">' +
                                '                <div class="wt1">' +
                                '                    <h6>' + _index + '.</h6>' +
                                '                    <div class="group-info" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam) + ')\'>' +
                                '                       <div class="icon bg-cover" style="background: url(' + ajaxUrl + jtem.team_data.icon_path + ')"></div>' +
                                '                         <p class="t-l">' + jtem.team_data.title + '</p>' +
                                '                    </div>' +
                                '                 </div>' +
                                '                 <div class="wt2"><em class="c-primary">' + jtem.win + '</em>/' + jtem.negative + '</div>' +
                                '                 <div class="wt2">' + jtem.win_rate + '%</div>' +
                                '                 <div class="wt2">' + jtem.win_mark + '</div>' +
                                '                 <div class="wt2">' + jtem.integral + '</div>' +
                                '            </div>' +
                                '       </li>';
                        })

                        groupHtml += '<div class="area-list-group">' +
                            '                    <div class="group-title">' +
                            '                        <p class="wt1 wt">' + item.title + '</p>' +
                            '                        <p class="wt2 wt"><em class="c-primary">胜</em>/负</p>' +
                            '                        <p class="wt2 wt">胜率</p>' +
                            '                        <p class="wt2 wt">净胜分</p>' +
                            '                        <p class="wt2 wt">积分</p>' +
                            '                    </div>' +
                            '                    <ul>' + liHtml + '</ul>' +
                            '                </div>';
                    } else if (item.leixing_type == 2) {
                        $.each(item.data, function (j, jtem) {
                            var _index = parseInt(j) + 1;
                            var teamParam = {"team_id": jtem.team_id};//右侧队伍id
                            var red = '';
                            if(_index <= 4){
                                red = 'red';
                            }
                            liHtml += '<li class="'+red+'">' +
                                '           <div class="group-list">' +
                                '                <div class="wt1">' +
                                '                    <h6>' + _index + '.</h6>' +
                                '                    <div class="group-info" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam) + ')\'>' +
                                '                       <div class="icon bg-cover" style="background: url(' + ajaxUrl + jtem.team_data.icon_path + ')"></div>' +
                                '                         <p class="t-l">' + jtem.team_data.title + '</p>' +
                                '                    </div>' +
                                '                 </div>' +
                                '                 <div class="wt3">' + jtem.win + '</div>' +
                                '                 <div class="wt2">' + jtem.flat_win + '</div>' +
                                '                 <div class="wt2">' + jtem.flat_negative + '</div>' +
                                '                 <div class="wt3">' + jtem.negative + '</div>' +
                                '                 <div class="wt2"><em class="c-primary">' + jtem.enter + '</em>/' + jtem.lose + '</div>' +
                                '                 <div class="wt3">' + jtem.integral + '</div>' +
                                '            </div>' +
                                '       </li>';
                        })

                        groupHtml += '<div class="area-list-group football">' +
                            '                    <div class="group-title">' +
                            '                        <p class="wt1 wt">' + item.title + '</p>' +
                            '                        <p class="wt3 wt">胜</p>' +
                            '                        <p class="wt2 wt">平(胜)</p>' +
                            '                        <p class="wt2 wt">平(负)</p>' +
                            '                        <p class="wt3 wt">负</p>' +
                            '                        <p class="wt2 wt"><em class="c-primary">进</em>/失</p>' +
                            '                        <p class="wt3 wt">积分</p>' +
                            '                    </div>' +
                            '                    <ul>' + liHtml + '</ul>' +
                            '                </div>';
                    }


                })

                $(".area-list-view").show();
                $("#groupHtml").html(groupHtml)


            } else {
                if(match_area_id == 171){
                    $(".area-list-view").hide()

                }else {
                    $(".area-list-view").show()
                    $("#groupHtml").html(noData)
                }

            }
        }, function (error) {
            $("#groupHtml").html(noData)
            pop.notice(error.msg);
        })
    }


    //切换赛季
    $("#select_season").on('change', function () {
        var _this = $(this);
        var _this_id = _this.val();
        console.log(_this_id)
        curr_season_id = _this_id;
        getMatchData()
    });

    //切换赛程
    $("#select_schedule").on('change', function () {
        var _this = $(this);
        var _this_id = _this.find('option:selected').attr('data-id');
        $('#curr_schedule').html(_this.val());
        curr_schedule_id = _this_id;
        getMatchData()

    });


    //切换赛事组
    $(".math_list_type").on('click', 'li', function () {
        /*$(".math_list_type li").removeClass("on");
        $(this).addClass("on");*/
        // $(".page_box").removeClass("on");
        // $(".page_box").eq($(this).index()).addClass("on");
        /*category_id = $(this).attr('data-id');
        getMatchData()
        getRanking();
        getSeason(1);
        getSeason(2);
        getSeason(3);*/

        var nav_id = $(this).attr('data-id');
        if(nav_id == 154){
            toLinks('match_index_data');
        }else if(nav_id == 155){
            toLinks('match_index_data2');
        }else if(nav_id == 156){
            toLinks('match_index_data3');
        }else if(nav_id == 173){
            toLinks('match_index_data4');
        }else if(nav_id == 201){
            toLinks('match_index_data5');
        }else {
            pop.notice('暂无数据')
        }

    });

    //切换赛事-区域
    $(".math_area_type").on('click', 'li', function () {
        $(".math_area_type li").removeClass("on");
        $(this).addClass("on");
        // $(".page_box").removeClass("on");
        // $(".page_box").eq($(this).index()).addClass("on");

        match_area_id = $(this).attr('data-id');
        getMatchData();
    });

    //切换 排名 - 赛程 - 球员榜
    $(".kinds-choose").on('click', 'li', function () {
        var _this = $(this);
        _this.addClass("on").siblings('li').removeClass("on");
        $(".section .view").eq(_this.index()).show().siblings('.view').hide();
        kinds_type = $(_this).attr('data-type');
        if (kinds_type == 1) {
            getSeason(3);
        } else {
            getSeason(2);
        }
    });

    //切换 球员榜 -排行
    $(".rank-label").on('click', 'li', function () {
        var _this = $(this);
        var labelName = _this.html();
        _this.addClass("on").siblings('li').removeClass("on");
        $(".label-name").html(labelName)

        ball_kinds_id = _this.attr('data-id');
        getMatchData();

    });


    $(".rank-view").height($(window).height() - $('.pad-height').outerHeight(true));


</script>
